<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数字常用的方法</title>
</head>
<body>
<script>
  //获得0~1之间的小数(包括零 不包括1)
  var rand = Math.random();
  console.log(rand);
  //将数字四舍五入取整
  var res1 = Math.round(15.6);
  console.log(res1);
  //将数字向上取整
  var res2 = Math.ceil(15.4);
  console.log(res2);
  //将数字向下取整
  var rse3 = Math.floor(15.4);
  console.log(rse3);
  //对数字进行取幂运算
  var res4 = Math.pow(2,2);
  console.log(res4);
  //对数字进行二次开根
  var res5 = Math.sqrt(4);
  console.log(res5);
  //对数值进行绝对值运算
  var res6 = Math.abs(-8);
  console.log(res6);
  //取出若干数字中的最大值
  var max = Math.max(1,-2,-7,399);
  console.log(399);
  //取出若干数字中的最小值
  var min = Math.min(1,2,-199,-29);
  console.log(min);
  //获得一个近似于Π的值
  console.log(Math.PI);
</script>
</body>
</html>